package domain.entities.impl;

import java.util.Set;

import domain.entities.interfaces.IContact;
import domain.entities.interfaces.IContactGroup;
import domain.entities.interfaces.IUser;

public class ContactGroup implements IContactGroup {

	private IUser user;
	private int groupId;
	private String groupName;
	private Set<IContact> contacts;
	private int version;



	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public ContactGroup() {
		super();
	}

	//ID
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#getGroupId()
	 */
	public int getGroupId() {
		return groupId;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#setGroupId(int)
	 */
	public void setGroupId(int groupId) {
		this.groupId = groupId;
	}


	//NAME
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#getGroupName()
	 */
	public String getGroupName() {
		return groupName;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#setGroupName(java.lang.String)
	 */
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}


	//CONTACTS
	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#getContacts()
	 */
	public Set<IContact> getContacts(){
		return contacts;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#getContact(int)
	 */
	public IContact getContact(int idContact) {

		IContact result = null;

		for(IContact c : contacts) {
			if(c.getId() == idContact) {
				result = c;
				break;
			}
		}

		return result;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#setContacts(java.util.Set)
	 */
	public void setContacts(Set<IContact> contacts){
		this.contacts = contacts;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#getUser()
	 */
	public IUser getUser() {
		return user;
	}

	/* (non-Javadoc)
	 * @see domain.entities.impl.IContactGroup#setUser(domain.entities.impl.User)
	 */
	public void setUser(IUser user) {
		this.user = user;
	}
}
